<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //    检测是否是本地电话，如010-12345678,0418-12345678

        while (true) {
            const reg = /^[0-9]{3,4}-\d{8}$/
            const a = prompt("请输入电话号码")
            if (reg.test(a)) {
                alert(`${a}是本地电话号码`)
            } else {
                alert(`${a}不是本地号码`)
            }
        }
    </script>

</body>

</html>